/*
 * Copyright 2018 JDCLOUD.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * 京东云function接口
 * function相关接口
 *
 * OpenAPI spec version: v1
 * Contact: 
 *
 * NOTE: This class is auto generated by the jdcloud code generator program.
 */


using JDCloudSDK.Core.Auth;
using JDCloudSDK.Core.Client;
using JDCloudSDK.Core.Http;
using JDCloudSDK.Function.Apis;
using JDCloudSDK.Function.Model;
using System;
using System.Collections.Generic;
using System.Text;
#if NET40||NET35
#else
using System.Threading.Tasks;
#endif

namespace JDCloudSDK.Function.Client
{
    /// <summary>
    ///  京东云function接口
    ///  function相关接口
    ///  Function Api 客户端
    ///</summary>
    public class FunctionClient : JdcloudClient
    {

        /// <summary>
        ///  默认私有构造函数
        /// </summary>
        private FunctionClient()
        {

        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="environment">sdk 环境配置信息</param>
        public FunctionClient(CredentialsProvider credentialsProvider, HttpRequestConfig httpRequestConfig,SDKEnvironment environment)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
            this.environment = environment;
        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="credentialsProvider">认证信息</param>
        public FunctionClient(CredentialsProvider credentialsProvider,HttpRequestConfig httpRequestConfig)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        /// 默认构造函数，
        /// 注意如果使用此方法 httpRequestConfig 使用的http 请求 schema 为Https
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        public FunctionClient(CredentialsProvider credentialsProvider)
        {
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        ///  版本号 1.1.0
        ///</summary>
        public const string ClientVersion = "1.1.0";

        private const string apiVersion = "v1";
        private const string userAgentPrefix = "JdcloudSdkDotNet";
        private const string defaultEndpoint = "function.jdcloud-api.com";
        private const string serviceName = "function";
        private const string userAgent = userAgentPrefix + "/" + ClientVersion + " " + serviceName + "/" + apiVersion;


        private SDKEnvironment environment = new SDKEnvironment(defaultEndpoint);
        private CredentialsProvider credentialsProvider;
        private HttpRequestConfig httpRequestConfig;

        /// <summary>
        ///  获取证书信息
        ///</summary>
        public override CredentialsProvider CredentialsProvider   { get { return credentialsProvider; } }

        /// <summary>
        ///  获取http 客户端配置信息
        ///</summary>
        public override HttpRequestConfig HttpRequestConfig { get { return httpRequestConfig; } }

        /// <summary>
        ///  获取sdk环境配置信息
        ///</summary>
        public override SDKEnvironment SDKEnvironment { get { return environment; } }

        /// <summary>
        ///  获取用户自定义浏览器识别字符串
        ///</summary>
        public override string UserAgent { get { return userAgent; } }

        /// <summary>
        ///  获取服务名称
        ///</summary>
        public override string ServiceName { get { return serviceName; } }

        /// <summary>
        ///  获取版本号
        ///</summary>
        public override string Version { get { return apiVersion; } }



#if NET40||NET35
        /// <summary>
        ///  创建别名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public CreateAliasResponse CreateAlias(CreateAliasRequest request) {
            return  new CreateAliasExecutor().Client(this).Execute<CreateAliasResponse, CreateAliasResult, CreateAliasRequest>(request);
        }
#else
        /// <summary>
        ///  创建别名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<CreateAliasResponse> CreateAlias(CreateAliasRequest request) {
            return await new CreateAliasExecutor().Client(this).Execute<CreateAliasResponse, CreateAliasResult, CreateAliasRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  获取版本详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetVersionResponse GetVersion(GetVersionRequest request) {
            return  new GetVersionExecutor().Client(this).Execute<GetVersionResponse, GetVersionResult, GetVersionRequest>(request);
        }
#else
        /// <summary>
        ///  获取版本详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetVersionResponse> GetVersion(GetVersionRequest request) {
            return await new GetVersionExecutor().Client(this).Execute<GetVersionResponse, GetVersionResult, GetVersionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  删除别名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public DeleteAliasResponse DeleteAlias(DeleteAliasRequest request) {
            return  new DeleteAliasExecutor().Client(this).Execute<DeleteAliasResponse, DeleteAliasResult, DeleteAliasRequest>(request);
        }
#else
        /// <summary>
        ///  删除别名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<DeleteAliasResponse> DeleteAlias(DeleteAliasRequest request) {
            return await new DeleteAliasExecutor().Client(this).Execute<DeleteAliasResponse, DeleteAliasResult, DeleteAliasRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  创建函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public CreateFunctionResponse CreateFunction(CreateFunctionRequest request) {
            return  new CreateFunctionExecutor().Client(this).Execute<CreateFunctionResponse, CreateFunctionResult, CreateFunctionRequest>(request);
        }
#else
        /// <summary>
        ///  创建函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<CreateFunctionResponse> CreateFunction(CreateFunctionRequest request) {
            return await new CreateFunctionExecutor().Client(this).Execute<CreateFunctionResponse, CreateFunctionResult, CreateFunctionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  创建版本
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public CreateVersionResponse CreateVersion(CreateVersionRequest request) {
            return  new CreateVersionExecutor().Client(this).Execute<CreateVersionResponse, CreateVersionResult, CreateVersionRequest>(request);
        }
#else
        /// <summary>
        ///  创建版本
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<CreateVersionResponse> CreateVersion(CreateVersionRequest request) {
            return await new CreateVersionExecutor().Client(this).Execute<CreateVersionResponse, CreateVersionResult, CreateVersionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询函数详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetFunctionResponse GetFunction(GetFunctionRequest request) {
            return  new GetFunctionExecutor().Client(this).Execute<GetFunctionResponse, GetFunctionResult, GetFunctionRequest>(request);
        }
#else
        /// <summary>
        ///  查询函数详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetFunctionResponse> GetFunction(GetFunctionRequest request) {
            return await new GetFunctionExecutor().Client(this).Execute<GetFunctionResponse, GetFunctionResult, GetFunctionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询版本列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public ListVersionResponse ListVersion(ListVersionRequest request) {
            return  new ListVersionExecutor().Client(this).Execute<ListVersionResponse, ListVersionResult, ListVersionRequest>(request);
        }
#else
        /// <summary>
        ///  查询版本列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<ListVersionResponse> ListVersion(ListVersionRequest request) {
            return await new ListVersionExecutor().Client(this).Execute<ListVersionResponse, ListVersionResult, ListVersionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  控制台测试执行函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public InvokeResponse Invoke(InvokeRequest request) {
            return  new InvokeExecutor().Client(this).Execute<InvokeResponse, InvokeResult, InvokeRequest>(request);
        }
#else
        /// <summary>
        ///  控制台测试执行函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<InvokeResponse> Invoke(InvokeRequest request) {
            return await new InvokeExecutor().Client(this).Execute<InvokeResponse, InvokeResult, InvokeRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  更新别名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public UpdateAliasResponse UpdateAlias(UpdateAliasRequest request) {
            return  new UpdateAliasExecutor().Client(this).Execute<UpdateAliasResponse, UpdateAliasResult, UpdateAliasRequest>(request);
        }
#else
        /// <summary>
        ///  更新别名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<UpdateAliasResponse> UpdateAlias(UpdateAliasRequest request) {
            return await new UpdateAliasExecutor().Client(this).Execute<UpdateAliasResponse, UpdateAliasResult, UpdateAliasRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  异步测试执行函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public AsyncInvokeResponse AsyncInvoke(AsyncInvokeRequest request) {
            return  new AsyncInvokeExecutor().Client(this).Execute<AsyncInvokeResponse, AsyncInvokeResult, AsyncInvokeRequest>(request);
        }
#else
        /// <summary>
        ///  异步测试执行函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<AsyncInvokeResponse> AsyncInvoke(AsyncInvokeRequest request) {
            return await new AsyncInvokeExecutor().Client(this).Execute<AsyncInvokeResponse, AsyncInvokeResult, AsyncInvokeRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  获取触发器详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetTriggerResponse GetTrigger(GetTriggerRequest request) {
            return  new GetTriggerExecutor().Client(this).Execute<GetTriggerResponse, GetTriggerResult, GetTriggerRequest>(request);
        }
#else
        /// <summary>
        ///  获取触发器详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetTriggerResponse> GetTrigger(GetTriggerRequest request) {
            return await new GetTriggerExecutor().Client(this).Execute<GetTriggerResponse, GetTriggerResult, GetTriggerRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  删除版本
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public DeleteVersionResponse DeleteVersion(DeleteVersionRequest request) {
            return  new DeleteVersionExecutor().Client(this).Execute<DeleteVersionResponse, DeleteVersionResult, DeleteVersionRequest>(request);
        }
#else
        /// <summary>
        ///  删除版本
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<DeleteVersionResponse> DeleteVersion(DeleteVersionRequest request) {
            return await new DeleteVersionExecutor().Client(this).Execute<DeleteVersionResponse, DeleteVersionResult, DeleteVersionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  删除函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public DeleteFunctionResponse DeleteFunction(DeleteFunctionRequest request) {
            return  new DeleteFunctionExecutor().Client(this).Execute<DeleteFunctionResponse, DeleteFunctionResult, DeleteFunctionRequest>(request);
        }
#else
        /// <summary>
        ///  删除函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<DeleteFunctionResponse> DeleteFunction(DeleteFunctionRequest request) {
            return await new DeleteFunctionExecutor().Client(this).Execute<DeleteFunctionResponse, DeleteFunctionResult, DeleteFunctionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询函数列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public ListFunctionResponse ListFunction(ListFunctionRequest request) {
            return  new ListFunctionExecutor().Client(this).Execute<ListFunctionResponse, ListFunctionResult, ListFunctionRequest>(request);
        }
#else
        /// <summary>
        ///  查询函数列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<ListFunctionResponse> ListFunction(ListFunctionRequest request) {
            return await new ListFunctionExecutor().Client(this).Execute<ListFunctionResponse, ListFunctionResult, ListFunctionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询别名列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public ListAliasResponse ListAlias(ListAliasRequest request) {
            return  new ListAliasExecutor().Client(this).Execute<ListAliasResponse, ListAliasResult, ListAliasRequest>(request);
        }
#else
        /// <summary>
        ///  查询别名列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<ListAliasResponse> ListAlias(ListAliasRequest request) {
            return await new ListAliasExecutor().Client(this).Execute<ListAliasResponse, ListAliasResult, ListAliasRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询别名详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetAliasResponse GetAlias(GetAliasRequest request) {
            return  new GetAliasExecutor().Client(this).Execute<GetAliasResponse, GetAliasResult, GetAliasRequest>(request);
        }
#else
        /// <summary>
        ///  查询别名详情
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetAliasResponse> GetAlias(GetAliasRequest request) {
            return await new GetAliasExecutor().Client(this).Execute<GetAliasResponse, GetAliasResult, GetAliasRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  更新函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public UpdateFunctionResponse UpdateFunction(UpdateFunctionRequest request) {
            return  new UpdateFunctionExecutor().Client(this).Execute<UpdateFunctionResponse, UpdateFunctionResult, UpdateFunctionRequest>(request);
        }
#else
        /// <summary>
        ///  更新函数
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<UpdateFunctionResponse> UpdateFunction(UpdateFunctionRequest request) {
            return await new UpdateFunctionExecutor().Client(this).Execute<UpdateFunctionResponse, UpdateFunctionResult, UpdateFunctionRequest>(request).ConfigureAwait(false);
        }
#endif

            /// <summary>
            ///  默认FunctionClient 构造器 接口
            ///</summary>
            public interface Builder
            {

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>functionClient 构造器</returns>
                Builder CredentialsProvider(CredentialsProvider provider);

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>functionClient 构造器</returns>
                Builder Environment(Core.Client.SDKEnvironment environment);

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>functionClient 构造器</returns>
                Builder HttpRequestConfig(HttpRequestConfig config);

                /// <summary>
                ///  构造FunctionClient 对象
                ///</summary>
                FunctionClient Build();
            }

            /// <summary>
            ///  默认FunctionClient 构造器
            ///</summary>
            public class DefaultBuilder : Builder
            {
                /// <summary>
                ///  FunctionClient service client
                /// </summary>
                private  FunctionClient functionClient;

                /// <summary>
                ///  默认FunctionClient 构造器构造对象
                ///</summary>
                public DefaultBuilder()
                {
                    functionClient = new FunctionClient();
                }

                /// <summary>
                ///  构造FunctionClient 对象
                ///</summary>
                public FunctionClient Build()
                {
                    if (functionClient.CredentialsProvider == null)
                    {
                        //if credentialsProvider not set, try load jdcloud global default  credentials provider
                        functionClient.credentialsProvider = JdCloud.DefaultInstance.GetCredentialsProvider();
                        if (functionClient.credentialsProvider == null)
                        {
                            throw new ArgumentNullException("FunctionClient build error: jdcloud credentials provider not set");
                        }
                    }
                    if (functionClient.HttpRequestConfig == null)
                    {
                        functionClient.httpRequestConfig = JdCloud.DefaultInstance.GetHttpRequestConfig();
                        if (functionClient.httpRequestConfig == null)
                        {
                        throw new ArgumentNullException("FunctionClient build error: http request config not set");
                        }
                    }
                    return functionClient;
                }

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>functionClient 构造器</returns>
                public Builder CredentialsProvider(CredentialsProvider provider)
                {
                    functionClient.credentialsProvider = provider;
                    return this;
                }

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>functionClient 构造器</returns>
                public Builder Environment(SDKEnvironment environment)
                {
                    functionClient.environment = environment;
                    return this;
                }

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>functionClient 构造器</returns>
                public Builder HttpRequestConfig(HttpRequestConfig config)
                {
                    functionClient.httpRequestConfig = config;
                    return this;
                }
            }
    }
}
